package vo;

import java.util.Date;

import util.Tool;

public class CreditCheckBean {
	private Integer applyid;
	private Integer clientid;
	private String customName;
	private Double applyMoney;
	private Date applyDate;
	private String applyType;
	private String applyTypeStr;
	private Integer applyTime;
	private String applyTimeType;
	private Integer applyState;
	private Integer buttonState;
	private Integer customerManager;
	
	private Double applybaserate;
	private Double slidingscale;
	private Double performrates;

	private String applyStateStr;
	private String buttonStateStr;
	
	private int isCanChange;
	
	private String doState;

	public CreditCheckBean() {

	}

	public CreditCheckBean(Integer applyid, String customName,
			Double applyMoney, Date applyDate) {
		super();
		this.applyid = applyid;
		this.customName = customName;
		this.applyMoney = applyMoney;
		this.applyDate = applyDate;
	}
	
	public CreditCheckBean(Integer applyid, String customName,
			Double applyMoney, Date applyDate, Integer applyTime,
			String applyTimeType, Integer applyState, String doState) {
		super();
		this.applyid = applyid;
		this.customName = customName;
		this.applyMoney = applyMoney;
		this.applyDate = applyDate;
		this.applyTime = applyTime;
		this.applyTimeType = applyTimeType;
		this.applyState = applyState;
		this.doState = doState;
		if(this.doState.equals("accept")){
			if(this.applyState == 1){
				this.applyStateStr = "等待受理";
				this.buttonStateStr = "查看";
				this.isCanChange = 1;
			}else if(this.applyState != 1){
				this.applyStateStr = "受理完成";
				this.buttonStateStr = "查看";
				this.isCanChange = 0;
			}
		}else if(this.doState.equals("survey")){
			if(this.applyState == 11){
				this.applyStateStr = "等待调查";
				this.buttonStateStr = "调查";
				this.isCanChange = 1;
			}else if(this.applyState == 12){
				this.applyStateStr = "上级返回";
				this.buttonStateStr = "查看/修改";
				this.isCanChange = 2;
			}else{
				this.applyStateStr = "正在审核";
				this.buttonStateStr = "查看";
				this.isCanChange = 0;
			}
		}else if(this.doState.equals("examine")){
			if(this.applyState == 21){
				this.applyStateStr = "等待审查";
				this.buttonStateStr = "审查";
				this.isCanChange = 1;
			}else if(this.applyState == 12){
				this.applyStateStr = "审查未通过";
				this.buttonStateStr = "查看";
				this.isCanChange = 0;
			}else if(this.applyState == 22){
				this.applyStateStr = "上级返回";
				this.buttonStateStr = "查看";
				this.isCanChange = 2;
			}else{
				this.applyStateStr = "审核通过";
				this.buttonStateStr = "查看";
				this.isCanChange = 0;
			}
		}else if(this.doState.equals("approval")){
			if(this.applyState == 31){
				this.applyStateStr = "等待审批";
				this.buttonStateStr = "审批";
				this.isCanChange = 1;
			}else if(this.applyState == 41){
				this.applyStateStr = "审批通过";
				this.buttonStateStr = "查看";
				this.isCanChange = 0;
			}else if(this.applyState == 32){
				this.applyStateStr = "上级返回";
				this.buttonStateStr = "查看";
				this.isCanChange = 2;
			}else{
				this.applyStateStr = "审批未通过";
				this.buttonStateStr = "查看";
				this.isCanChange = 0;
			}
		}else if(this.doState.equals("finalApproval")){
			if(this.applyState == 41){
				this.applyStateStr = "等待终审";
				this.buttonStateStr = "终审";
				this.isCanChange = 1;
			}else{
				this.applyStateStr = "终审未通过";
				this.buttonStateStr = "查看";
				this.isCanChange = 0;
			}
		}else if(this.doState.equals("advice")){
			if(this.applyState == 0){
				this.applyStateStr = "未填写意见";
				this.buttonStateStr = "填写意见";
				this.isCanChange = 1;
			}else if(this.applyState == 1){
				this.applyStateStr = "已填写意见";
				this.buttonStateStr = "查看";
				this.isCanChange = 0;
			}
		}
		
	}

	public CreditCheckBean(Integer applyid, String customName, String applyType,
			Double applyMoney, Date applyDate, Integer applyTime,
			String applyTimeType, Double applybaserate,
			Double slidingscale, Double performrates) {
		super();
		this.applyid = applyid;
		this.customName = customName;
		this.applyType = applyType;
		this.applyMoney = applyMoney;
		this.applyDate = applyDate;
		this.applyTime = applyTime;
		this.applyTimeType = applyTimeType;
		this.applybaserate = applybaserate;
		this.slidingscale = slidingscale;
		this.performrates = performrates;
		
		this.applyTypeStr = this.exchangeApplyType(applyType);
	}
	
	public CreditCheckBean(Integer applyid, Integer clientid, String customName, String applyType,
			Double applyMoney, Date applyDate, Integer applyTime,
			String applyTimeType, Double applybaserate,
			Double slidingscale, Double performrates) {
		super();
		this.applyid = applyid;
		this.clientid = clientid;
		this.customName = customName;
		this.applyType = applyType;
		this.applyMoney = applyMoney;
		this.applyDate = applyDate;
		this.applyTime = applyTime;
		this.applyTimeType = applyTimeType;
		this.applybaserate = applybaserate;
		this.slidingscale = slidingscale;
		this.performrates = performrates;
		
		this.applyTypeStr = this.exchangeApplyType(applyType);
	}

	public Integer getApplyid() {
		return applyid;
	}

	public void setApplyid(Integer applyid) {
		this.applyid = applyid;
	}

	public String getCustomName() {
		return customName;
	}

	public void setCustomName(String customName) {
		this.customName = customName;
	}

	public Double getApplyMoney() {
		return applyMoney;
	}

	public void setApplyMoney(Double applyMoney) {
		this.applyMoney = applyMoney;
	}

	public Date getApplyDate() {
		return applyDate;
	}

	public void setApplyDate(Date applyDate) {
		this.applyDate = applyDate;
	}


	public Integer getApplyState() {
		return applyState;
	}

	public void setApplyState(Integer applyState) {
		this.applyState = applyState;
	}

	public Integer getButtonState() {
		return buttonState;
	}

	public void setButtonState(Integer buttonState) {
		this.buttonState = buttonState;
	}

	public String getApplyStateStr() {
		return applyStateStr;
	}

	public void setApplyStateStr(String applyStateStr) {
		this.applyStateStr = applyStateStr;
	}

	public String getButtonStateStr() {
		return buttonStateStr;
	}

	public void setButtonStateStr(String buttonStateStr) {
		this.buttonStateStr = buttonStateStr;
	}

	public Integer getCustomerManager() {
		return customerManager;
	}

	public void setCustomerManager(Integer customerManager) {
		this.customerManager = customerManager;
	}

	public int getIsCanChange() {
		return isCanChange;
	}

	public void setIsCanChange(int isCanChange) {
		this.isCanChange = isCanChange;
	}

	

	public Double getApplybaserate() {
		return applybaserate;
	}

	public void setApplybaserate(Double applybaserate) {
		this.applybaserate = applybaserate;
	}

	public Double getSlidingscale() {
		return slidingscale;
	}

	public void setSlidingscale(Double slidingscale) {
		this.slidingscale = slidingscale;
	}

	public Double getPerformrates() {
		return performrates;
	}

	public void setPerformrates(Double performrates) {
		this.performrates = performrates;
	}
	

	public Integer getApplyTime() {
		return applyTime;
	}

	public void setApplyTime(Integer applyTime) {
		this.applyTime = applyTime;
	}

	public String getApplyTimeType() {
		return applyTimeType;
	}

	public void setApplyTimeType(String applyTimeType) {
		this.applyTimeType = applyTimeType;
	}

	public String getDoState() {
		return doState;
	}

	public void setDoState(String doState) {
		this.doState = doState;
	}

	public String getApplyType() {
		return applyType;
	}

	public void setApplyType(String applyType) {
		this.applyType = applyType;
	}

	public String getApplyTypeStr() {
		return applyTypeStr;
	}

	public void setApplyTypeStr(String applyTypeStr) {
		this.applyTypeStr = applyTypeStr;
	}
	
	public String exchangeApplyType(String applyType){
		String str = "";
		String[] types = Tool.splitArrayHtml(applyType);
		if(this.modelHave(types, "1")){
			str += "抵押,";
		}
		if(this.modelHave(types, "2")){
			str += "质押,";
		}
		if(this.modelHave(types, "3")){
			str += "保证,";
		}
		if(this.modelHave(types, "4")){
			str += "信用";
		}
		return str;
	}
	
	public boolean modelHave(String[] types, String str){
		for(String type : types){
			if(type.equals(str)){
				return true;
			}
		}
		return false;
	}

	public Integer getClientid() {
		return clientid;
	}

	public void setClientid(Integer clientid) {
		this.clientid = clientid;
	}

	@Override
	public String toString() {
		return "CreditCheckBean [applyid=" + applyid + ", customName="
				+ customName + ", applyMoney=" + applyMoney + ", applyDate="
				+ applyDate + ", applyTime=" + applyTime + ", applyTimeType="
				+ applyTimeType + ", applyState=" + applyState
				+ ", buttonState=" + buttonState + ", customerManager="
				+ customerManager + ", applybaserate=" + applybaserate
				+ ", slidingscale=" + slidingscale + ", performrates="
				+ performrates + ", applyStateStr=" + applyStateStr
				+ ", buttonStateStr=" + buttonStateStr + ", isCanChange="
				+ isCanChange + "]";
	}
}
